
struct IDirectInput8;
struct IDirectInputDevice8;
class IInputListener;
enum EKeyboardButtonID;

class CInputManager
{
public:

    CInputManager();
    void Update(IInputListener* pInputListener);
    bool FInitialize();
    void Cleanup();

    int GetMouseX();
    int GetMouseY();

    bool IsKeyDown(EKeyboardButtonID eButtonID);

private:
    void ProcessKeyboardData(IInputListener* pInputListener);

    void ProcessMouseData(IInputListener* pInputListener);
    bool FCaptureMouse(IInputListener* pInputListener);
    bool FCaptureKeyboard(IInputListener* pInputListener);

    void ProcessDIMouseMove(IInputListener* pInputListener, int dx, int dy, int dz);
    void ProcessWindowMouseMove(IInputListener* pInputListener);
    bool IsMouseInWindow();

    IDirectInput8* m_pDirectInput;
    IDirectInputDevice8* m_pKeyboardDevice;
    IDirectInputDevice8* m_pMouseDevice;


    struct MOUSESTATE
    {
        int  iXPosition;
        int  iYPosition;
        int  iZPosition;
        unsigned char bButtons;
    };

    MOUSESTATE m_mouseState;

    static const int c_uiMouseSampleBufferSize = 32;
    static const int c_uiKeyboardSampleBufferSize = 64;
    static const int c_uiKeyboardStateLen = 256;

    unsigned char m_rgbKeyboardState[c_uiKeyboardStateLen];

    bool m_fKeyboardAcquired;
    bool m_fMouseAcquired;
    bool m_fUseDIMouseMotion;
};
